package com.opennews.openplatform.familyexpenseapi.security

import com.opennews.openplatform.familyexpenseapi.entity.Tables
import com.opennews.openplatform.familyexpenseapi.entity.tables.records.RequestMapRecord
import com.opennews.openplatform.myspringbootcore.dto.RequestMap
import com.opennews.openplatform.myspringbootcore.security.RequestMapQuery
import org.jooq.DSLContext
import org.springframework.stereotype.Component

@Component
class SecurityRequestMapQuery(
    private val dslContext: DSLContext,
) : RequestMapQuery {
    override fun queryAll(): MutableList<RequestMap> {
        return dslContext.selectFrom(Tables.REQUEST_MAP)
            .fetch()
            .map { record: RequestMapRecord ->
                RequestMap(
                    configAttribute = record.configAttribute,
                    httpMethod = record.httpMethod,
                    url = record.url,
                )
            }
    }
}